using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy_Skeleton : Enemy
{

    #region 状态声明 State
    public SkeletonIdleState idleState { get; private set; }// 待机状态
    public SkeletonMoveState moveState { get; private set; }// 移动状态
    public SkeletonBattleState battleState { get; private set; }// 战斗状态
    public SkeletonAttackState attackState { get; private set; }// 攻击状态
    public SkeletonStunnedState stunnedState { get; private set; }// 震晕状态
    public SkeletonDeadState deadState { get; private set; }//死亡状态



    #endregion
    protected override void Awake()
    {
        base.Awake();

        #region 实例化状态
        idleState = new SkeletonIdleState(this, stateMachine, "Idle", this);// 实例化待机状态
        moveState = new SkeletonMoveState(this, stateMachine, "Move", this);// 实例化移动状态
        battleState = new SkeletonBattleState(this, stateMachine, "Move", this);// 实例化战斗状态
        attackState = new SkeletonAttackState(this, stateMachine, "Attack", this);// 实例化攻击状态
        stunnedState = new SkeletonStunnedState(this, stateMachine, "Stunned", this);// 实例震晕化状态
        deadState = new SkeletonDeadState(this, stateMachine, "Idle", this);// 实例死亡状态


        #endregion
    }

    protected override void Start()
    {
        base.Start();
        stateMachine.Initialize(idleState);// 状态机初始化
    }

    protected override void Update()
    {
        base.Update();
    }

    // 判断是否能被击晕(重写函数)
    public override bool IsCanBeStunned()
    {
        if (base.IsCanBeStunned())
        {
            stateMachine.ChangeState(stunnedState);
            return true;
        }
        return false;
    }

    public override void Die()
    {
        base.Die();
        stateMachine.ChangeState(deadState);
    }
}
